import http from "../utils/request";
// 报名相关接口

export function demoApi1(query) {
  return http({
    url: "https://36477833br.oicp.vip/datasience/vbap3/imageManage/getImageList",
    method: "get",
    params: query,
  });
}

export function demoApi2(data) {
  return http({
    url: "http://172.16.14.124:9908/api/datamap/openDatamap/zl/retire/save",
    method: "post",
    data: data,
  });
}

// https://console-docs.apipost.cn/preview/a6c8ad97c883680d/938460150d5bd6fa?target_id=9ada089c-f1f0-4451-97c0-325b62c898a7
// 登录
export function login(data) {
  return http({
    url: "/underwater-sound/login",
    method: "post",
    data: data,
  });
}
// 修改密码
export function updatePassword(data) {
  return http({
    url: "/underwater-sound/updatePassword",
    method: "post",
    data: data,
  });
}

export function getUsername() {
  return http({
    url: "/underwater-sound/getUsername",
    method: "get",
  });
}

// 原始数据存储与管理平台
// 修改excel表格数据
export function updateTempExcelData(data) {
  return http({
    url: "/underwater-sound/tempFileManage/updateTempExcelData",
    method: "post",
    data: data,
  });
}
// 查询excel表格数据
export function getTempListByExcelTable(query) {
  return http({
    url: `/underwater-sound/tempFileManage/getTempListByExcelTable`,
    method: "get",
    params: query,
  });
}
// 获取所有文件类型
export function getFileClassification(query) {
  return http({
    url: "/underwater-sound/tempFileManage/getFileClassification",
    method: "get",
    params: query,
  });
}
// 新增文件
export function addTempFile(data) {
  return http({
    url: "/underwater-sound/tempFileManage/addTempFile",
    method: "post",
    "Content-Type":
      "multipart/form-data; boundary=--------------------------429878037138410491126507",
    data: data,
  });
}
// 获取主机地址
export function getHost(query) {
  return http({
    url: "/underwater-sound/tempFileManage/getLocalHost",
    method: "get",
    params: query,
  });
}
// 修改信息
export function updateTempFileInfo(data) {
  return http({
    url: "/underwater-sound/tempFileManage/updateTempFileInfo",
    method: "post",
    data: data,
  });
}
// 分页查询文件与转换后文件
export function getTempListByFileClassification(query) {
  return http({
    url: `/underwater-sound/tempFileManage/getTempListByFileClassification`,
    method: "get",
    params: query,
  });
}
// 下载文件到本地
export function exportFile(data) {
  return http({
    url: "/underwater-sound/tempFileManage/exportFile",
    method: "post",
    responseType: "blob",
    data: data,
  });
}
// 下载excel表数据
export function exportExcelData(data, fileId) {
  return http({
    url: `/underwater-sound/tempFileManage/exportExcelData/${fileId}`,
    method: "post",
    responseType: "blob",
    data: data,
  });
}
// 移出处理后文件区域
export function shiftOutConversion(data, convertType) {
  return http({
    url: `/underwater-sound/tempFileManage/shiftOutConversion/` + convertType,
    method: "post",
    data: data,
  });
}
export function dataProcessing(data) {
  return http({
    url: `/underwater-sound/tempFileManage/dataProcessing`,
    method: "post",
    data: data,
  });
}

// 一键清除按钮
export function clearTempDataAndFile() {
  return http({
    url: `/underwater-sound/tempFileManage/clearTempDataAndFile`,
    method: "get",
  });
}

export function test0() {
  // var xhr = new XMLHttpRequest();
  // xhr.open(
  //   "GET",
  //   "/dev-api/underwater-sound/algorithmManagement/downloadFile?algorithmId=SSFXc0c60d1c456248e0ad95975870f656ba&fileType=0",
  //   true
  // );
  // xhr.setRequestHeader("Authorization", `Bearer ${store.state.token}`);
  // xhr.send();
  // window.open(
  //   "http://192.168.3.89:8080/dev-api/underwater-sound/algorithmManagement/downloadFile?algorithmId=SSFXc0c60d1c456248e0ad95975870f656ba&fileType=0"
  // );
  return http({
    url: `/underwater-sound/algorithmManagement/downloadFile?algorithmId=SSFXc0c60d1c456248e0ad95975870f656ba&fileType=0`,
    method: "get",
  });
}

export function getImageNames() {
  return http({
    url: `/underwater-sound/sse/getImagePath`,
    method: "get",
  });
}

export function getImage(name) {
  return http({
    url: `/underwater-sound/imageResult/${name}`,
    method: "get",
    responseType: "blob",
  });
}
//新修改的
export function queryAlgorithmResult(data) {
  return http({
    url: `/underwater-sound/dataAlgorithmsProcessing/queryAlgorithmResultData`,
    method: "post",
    data: data,
  });
}

export function updateTaskViewStatus(taskId) {
  return http({
    url: `/underwater-sound/dataAlgorithmsProcessing/updateTaskViewStatus?taskId=${taskId}`,
    method: "get",
  });
}

export function dataAlgorithmsProcessing(query) {
  return http({
    url: `/underwater-sound/dataAlgorithmsProcessing/queryAlgorithm`,
    method: "get",
    params: query,
  });
}

// 新增文件
export function diyUpload(data) {
  return http({
    url: "/underwater-sound/customizeAlgorithm/uploadFile",
    method: "post",
    "Content-Type":
      "multipart/form-data; boundary=--------------------------429878037138410491126507",
    data: data,
  });
}

export function addCustomAlgorithm(data) {
  return http({
    url: `/underwater-sound/customizeAlgorithm/addAlgorithm`,
    method: "post",
    data: data,
  });
}

export function queryCustomizeAlgorithm(data) {
  return http({
    url: `/underwater-sound/customizeAlgorithm/queryCustomizeAlgorithm`,
    method: "post",
    data: data,
  });
}

export function deleteCustomizeAlgorithm(id) {
  return http({
    url: `/underwater-sound/customizeAlgorithm/delete/${id}`,
    method: "get",
  });
}

export function getColHisById2(id) {
  return http({
    url: `/underwater-sound/metadataDictyTable/getColHis`,
    method: "get",
  });
}
export function editModelName(data) {
  return http({
    url: `/underwater-sound/metadataDictyTable/updateMetadataModel`,
    method: "post",
    data: data,
  });
}

export function executeCustomAlgorithm(id) {
  return http({
    url: `/underwater-sound/customizeAlgorithm/executeAlgorithm/${id}`,
    method: "get",
  });
}


export function updateCustomAlgorithm(data) {
  return http({
    url: `/underwater-sound/customizeAlgorithm/updateAlgorithm`,
    method: "post",
    data: data,
  });
}
